package com.bing.img.controller;

import com.bing.img.model.Img;
import com.bing.img.service.IImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Zhou Bing
 * <p>
 * 2017/11/15.
 */
@RestController
@RequestMapping("/img")
public class ImgController {


    @Autowired
    IImgService imgService;

    @RequestMapping(value = "/getImg", method = RequestMethod.POST)
    public ResponseEntity<Img> getImg(String id){
        return ResponseEntity.ok(imgService.findImgById(id));
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public ResponseEntity<Img> saveImg(String base64){
        Img img  = imgService.saveImg(base64);
        return ResponseEntity.ok(img);
    }

}
